/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('sasti', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model DescribeDomainReportRequest {
  domain?: string(name='Domain', example='example.com'),
  field?: string(name='Field', example='ThreatTypes,Intelligences,AttackPreferenceTop5,AttackCntByThreatType'),
  serviceLang?: string(name='ServiceLang'),
}

model DescribeDomainReportResponseBody = {
  attackCntByThreatType?: string(name='AttackCntByThreatType'),
  attackPreferenceTop5?: string(name='AttackPreferenceTop5', example='[{"event_cnt":586,"industry_name":"Gaming","gmt_last_attack":"2020-06-14 21:54:04"}]'),
  basic?: string(name='Basic', example='{ "ip_cnt": "36", "domain": "example.com", "child_domain_cnt": "18", "sld_domain": "example.com", "malicious_ip_cnt": "28", "malicious_child_domain_cnt": "4" }'),
  confidence?: string(name='Confidence', example='95'),
  context?: string(name='Context', example='""'),
  domain?: string(name='Domain', example='example.com'),
  group?: string(name='Group', example='""'),
  intelligences?: string(name='Intelligences'),
  requestId?: string(name='RequestId', example='718747A4-9A75-4130-88F9-C9B47350B7F5'),
  scenario?: string(name='Scenario'),
  sslCert?: string(name='SslCert', example='{   "serial_number": "18395475168054001104",   "validity_end": "2029-12-02 06:00:31",   "issuer": "example.ca",...}'),
  threatLevel?: string(name='ThreatLevel', example='2'),
  threatTypes?: string(name='ThreatTypes'),
  whois?: string(name='Whois'),
}

model DescribeDomainReportResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeDomainReportResponseBody(name='body'),
}

async function describeDomainReportWithOptions(request: DescribeDomainReportRequest, runtime: Util.RuntimeOptions): DescribeDomainReportResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.domain)) {
    query['Domain'] = request.domain;
  }
  if (!Util.isUnset(request.field)) {
    query['Field'] = request.field;
  }
  if (!Util.isUnset(request.serviceLang)) {
    query['ServiceLang'] = request.serviceLang;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeDomainReport',
    version = '2020-05-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeDomainReport(request: DescribeDomainReportRequest): DescribeDomainReportResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeDomainReportWithOptions(request, runtime);
}

model DescribeFileReportRequest {
  field?: string(name='Field', example='ThreatTypes,Intelligences,AttackPreferenceTop5,AttackCntByThreatType'),
  fileHash?: string(name='FileHash'),
  serviceLang?: string(name='ServiceLang'),
}

model DescribeFileReportResponseBody = {
  basic?: string(name='Basic'),
  fileHash?: string(name='FileHash', example='02e6b7cf0d34c6eac059f754b751208b'),
  intelligences?: string(name='Intelligences'),
  requestId?: string(name='RequestId', example='3F2BBCA2-4EE5-456F-93B1-DE0B69CAFD71'),
  sandbox?: string(name='Sandbox', example='""'),
  threatLevel?: string(name='ThreatLevel', example='2'),
  threatTypes?: string(name='ThreatTypes'),
}

model DescribeFileReportResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeFileReportResponseBody(name='body'),
}

async function describeFileReportWithOptions(request: DescribeFileReportRequest, runtime: Util.RuntimeOptions): DescribeFileReportResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.field)) {
    query['Field'] = request.field;
  }
  if (!Util.isUnset(request.fileHash)) {
    query['FileHash'] = request.fileHash;
  }
  if (!Util.isUnset(request.serviceLang)) {
    query['ServiceLang'] = request.serviceLang;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeFileReport',
    version = '2020-05-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeFileReport(request: DescribeFileReportRequest): DescribeFileReportResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeFileReportWithOptions(request, runtime);
}

model DescribeIpReportRequest {
  field?: string(name='Field', example='TagsThreatTypes,Intelligences,AttackPreferenceTop5,AttackCntByThreatType'),
  ip?: string(name='Ip', example='192.0.XX.XX'),
  serviceLang?: string(name='ServiceLang'),
}

model DescribeIpReportResponseBody = {
  attackCntByThreatType?: string(name='AttackCntByThreatType'),
  attackPreferenceTop5?: string(name='AttackPreferenceTop5'),
  confidence?: string(name='Confidence', example='"98"'),
  context?: string(name='Context', example='""'),
  group?: string(name='Group', example='""'),
  intelligences?: string(name='Intelligences'),
  ip?: string(name='Ip'),
  requestId?: string(name='RequestId', example='BE036526-FE84-46A8-9165-F086E9810E2F'),
  scenario?: string(name='Scenario'),
  threatLevel?: string(name='ThreatLevel', example='"3"'),
  threatTypes?: string(name='ThreatTypes'),
  whois?: string(name='Whois', example='{   "serial_number": "18395475168054001104",...}'),
}

model DescribeIpReportResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeIpReportResponseBody(name='body'),
}

async function describeIpReportWithOptions(request: DescribeIpReportRequest, runtime: Util.RuntimeOptions): DescribeIpReportResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.field)) {
    query['Field'] = request.field;
  }
  if (!Util.isUnset(request.ip)) {
    query['Ip'] = request.ip;
  }
  if (!Util.isUnset(request.serviceLang)) {
    query['ServiceLang'] = request.serviceLang;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeIpReport',
    version = '2020-05-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeIpReport(request: DescribeIpReportRequest): DescribeIpReportResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeIpReportWithOptions(request, runtime);
}

